package com.ruoyi.partybuilding.controller;

import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.map.MapUtil;
import com.alibaba.fastjson2.JSONObject;
import com.easy.query.api4j.select.Queryable;
import com.easy.query.api4j.util.EasyLambdaUtil;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.partybuilding.common.*;
import com.ruoyi.partybuilding.common.EQuery.IDeptEntity;
import com.ruoyi.partybuilding.domain.*;
import com.ruoyi.partybuilding.domain.vo.DeptOrgVo;
import com.ruoyi.partybuilding.domain.vo.ScoreYearStatVo;
import com.ruoyi.partybuilding.service.impl.OrgServiceImpl;
import com.ruoyi.partybuilding.service.impl.WorkScoreServiceImpl;
import io.swagger.annotations.*;
import lombok.var;
import org.apache.commons.collections4.keyvalue.DefaultKeyValue;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.util.function.Tuple2;
import reactor.util.function.Tuple4;
import reactor.util.function.Tuple6;
import reactor.util.function.Tuples;

import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;


@Api(tags = "用户大屏")
@RestController
@RequestMapping("/partybuilding/UDeptDataStat")
public class UDpetDataStatController extends DataStatController {

    @Resource
    OrgServiceImpl orgService;
    @Resource
    WorkScoreServiceImpl scoreService;

    //党员
    @Cacheable(cacheNames = "dataStat" ,keyGenerator = "classMethodKey")
    @ApiOperation(value = "党员统计信息",notes = "t1党员统计[[值,说明]],t2汉族人数，t3学历[[值,说明]]，t4男性人数(总数在党员统计中),t5男性年龄分布[[值,说明]],t6女性年龄分布[[值,说明]]")
    @ApiResponse(code = 200, message = "成功示例", examples = @Example({@ExampleProperty(ConstData.DataStatMemberExample)}))
    @GetMapping(value = "memberStat")
    public R<Tuple6<List<Comparable[]>, Long, List<Comparable[]>, Long, List<Comparable[]>,List<Comparable[]>>> memberStat(Long deptId) {

        deptId = getDeptId();
        return super.memberStat(deptId);
    }


    @ApiOperation(value = "站点统计信息",notes = "t1文章数，t2栏目数,t3{栏目:文章数}对象")
    @GetMapping(value = "webStat")
    public R<Tuple2<Long,Long>> webStat(Long deptId) {
       return  super.webStat(getDeptId());
    }


    //组织
    @ApiOperation(value = "组织统计信息",notes = "t1组织数,t2党委数,t3总支数,t4支部数,t5党员数")
    @GetMapping(value = "OrgStat")
    public R  OrgStat(Long deptId) {
        deptId=getDeptId();
       return super.OrgStat(deptId);
    }
    //积分
    @ApiOperation(value = "积分统计信息",notes = "t1党员排名,t2组织排名-statMember表示人员数量;deptId党员排名的部门范围")
    @GetMapping(value = "ScoreStat")
    public R<Tuple2<List<ScoreYearStatVo>, List<ScoreYearStatVo>>> ScoreStat(Integer year, Integer top,Long deptId) {
        deptId=getDeptId();
        return super.ScoreStat(year, top, deptId);
    }

    @ApiOperation(value = "评议统计信息",notes = "t1开展组织数，t2参与用户数")
    @GetMapping(value = "reviewStat")
    public R<Tuple2<Long,Long>> reviewStat(Long deptId) {

        deptId = getDeptId();
        return super.reviewStat(deptId);
    }


    @ApiOperation(value = "评议列表",notes = "")
    @GetMapping(value = "reviewList")
    public TableDataInfoRows<Review> reviewList(Review review, PageDomain pageRequest,Long deptId) {

        deptId=getDeptId();
        return super.reviewList(review, pageRequest, deptId);
    }

    //会议
    @ApiOperation(value = "会议统计",notes = "t1党支部党员大会(0),t2支部委员会(1),t3党小组会(2),t4党课(3)")
    @GetMapping(value = "meetingStat")
    public R<Tuple4<Long,Long,Long,Long>> meetingStat(Long deptId) {
        deptId=getDeptId();
       return super.meetingStat(deptId);
    }
}